<?php

/**
 * Description of listLand
 *
 * @author MariiTeheran
 */
require_once '../conexion.php';
require_once '../objects/land.php';

class listLand {

    private $conx;
    private $table = "";
    private $sql = "SELECT * FROM LAND WHERE userid='%s'";

    public function __construct() {
        $this->conx = null;
    }

    public function listLand($id) {
        $consult = sprintf($this->sql, $id);
        $this->conx = new conexion();
        $result = pg_exec($this->conx->getConexionDB(), $consult);
        $this->conx->closeConexionDB();
        $this->conx = null;
        if (!$result) {
            echo 'Error al consultar las fincas \n';
        } while ($rows = pg_fetch_row($result)) {
            echo "<option value={$rows[0]}>{$rows[1]}</option>";
        }
        return $this->table;
    }
    
    public function listLandName($id) {
        $consult = sprintf($this->sql, $id);
        $this->conx = new conexion();
        $result = pg_exec($this->conx->getConexionDB(), $consult);
        $this->conx->closeConexionDB();
        $this->conx = null;
        if (!$result) {
            echo 'Error al consultar las fincas \n';
        } while ($rows = pg_fetch_row($result)) {
            echo "<option value='{$rows[0]}'>{$rows[1]}</option>";
        }
        return $this->table;
    }

}

?>
